/***************************************************************
|	File:		Entity.h
|	Author:		
|	Course:		
|	Purpose:	Entity class stores the shared data members
|				for all child game entities
***************************************************************/

#ifndef ENTITY_H
#define ENTITY_H


#include "IEntity.h"						// IEntity type
#include "../SGD Wrappers/SGD_Geometry.h"		// HTexture type
#include "../SGD Wrappers/SGD_Handle.h"
#include "../SGD Wrappers/SGD_GraphicsManager.h"
#include <list>;
#include <vector>;

using namespace std;

class DataWerehousee;
/**************************************************************/
// Entity class
//	- parent class of all game entities, stores the shared data members
//	- velocity-based movement



struct StankNode
{
	SGD::Size m_StankSize;
	SGD::Point m_OriginOffset;
	SGD::Point m_origin;
	SGD::Rectangle m_recStankVolume;


	float m_iDecayTime = 5.0f;

	bool Update(float ElaspedTime)
	{
		m_iDecayTime -= ElaspedTime;

		if (m_iDecayTime <= 0)
		{
			return false;
		}

		return true;
	}

	bool operator==(const StankNode& rhs)
	{

		if (rhs.m_origin == this->m_origin && rhs.m_iDecayTime == this->m_iDecayTime &&
			rhs.m_OriginOffset == this->m_OriginOffset && rhs.m_recStankVolume == this->m_recStankVolume &&
			rhs.m_recStankVolume == this->m_recStankVolume && rhs.m_StankSize == this->m_StankSize)
			return true;
		else
			return false;
	}

	bool operator!=(const StankNode& rhs)
	{

		if (rhs.m_origin != this->m_origin || rhs.m_iDecayTime != this->m_iDecayTime ||
			rhs.m_OriginOffset != this->m_OriginOffset || rhs.m_recStankVolume != this->m_recStankVolume ||
			rhs.m_recStankVolume != this->m_recStankVolume || rhs.m_StankSize != this->m_StankSize)
			return true;
		else
			return false;

	}

};

class Entity : public IEntity
{
#define	SMELL_CREATE_TIMER  0.3f

	/**********************************************************/
	// MUST have a virtual destructor to allow upcasted pointers
	// to trigger children destructors at deallocation

protected:
	virtual ~Entity( void );			// VIRTUAL destructor

	
public:
	/**********************************************************/

	Entity(void) = default;	// default constructor
	// Entity Types:
	enum EntityType { ENT_BASE,ENT_PACK, ENT_PLAYER, ENT_ANIMAL };



	list<StankNode*> m_ListSmellTrail;
	
	/**********************************************************/
	// Interface:
	//	- virtual functions for children classes to override
	virtual void	Update			( float elapsedTime )	;
	virtual void	Render			( void )				;
	virtual int		GetType			( void )	const	{	return ENT_BASE;	}
	virtual SGD::Rectangle GetRect(void)	const;
	virtual void	HandleCollision	( const IEntity* pOther );
	virtual void	PreformBehavaior(void) ;
	virtual void	SetCamOffset(SGD::Point);
	virtual void	CheckLoS();
	virtual vector<Entity*> InLineOfSight();

	//Creation Methods
	Entity::StankNode* CreateSmellNode(Entity* _Entity);


	//DataWerehouse*  m_ptBrain = nullptr;
	
	/**********************************************************/
	// Accessors:
	SGD::HTexture		GetImage	( void ) const			{	return m_hImage;		}
	SGD::Point			GetPosition	( void ) const			{	return m_ptPosition;	}
	SGD::Vector			GetVelocity	( void ) const			{	return m_vtVelocity;	}
	SGD::Size			GetSize		( void ) const			{	return m_szSize;		}
	float				GetRotation	( void ) const			{	return m_fRotation;		}

	// Mutators:
	void				SetImage	( SGD::HTexture	img  )	{	m_hImage		= img;	}
	void				SetPosition	( SGD::Point	pos  ) 	{	m_ptPosition	= pos;	}
	void				SetVelocity	( SGD::Vector	vel	 ) 	{	m_vtVelocity	= vel;	}
	void				SetSize		( SGD::Size		size ) 	{	m_szSize		= size;	}
	void				SetRotation ( float			rad  )	{	m_fRotation		= rad;	}

	//Possible Protected members
	SGD::Rectangle		m_recSmellRect = SGD::Rectangle(0, 0, 0, 0);
	SGD::Rectangle		m_recCollide = SGD::Rectangle(0, 0, 0, 0);

protected:
	/**********************************************************/
	// members:
	SGD::HTexture		m_hImage		= SGD::INVALID_HANDLE;	// image handle
	SGD::Point			m_ptPosition	= SGD::Point{0, 0};		// 2D position
	SGD::Vector			m_vtVelocity	= SGD::Vector{0, 0};	// 2D velocity
	SGD::Size			m_szSize = SGD::Size{ 0, 0 };		// 2D size
	SGD::Size			m_szSmellSize = SGD::Size{ 0, 0 };


	float				m_fRotation		= 0.0f;					// angle in radians
	float				 m_fSmellCreateControl = 0;

	

private:
	/**********************************************************/
	// reference count
	//unsigned int		m_unRefCount	= 1;	// calling 'new' gives the prime reference
};

#endif //ENTITY_H
